package presentacion;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import dominio.Empleado;

import java.awt.GridBagLayout;

import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JOptionPane;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.ButtonGroup;
import javax.swing.JMenuItem;
import javax.swing.JLabel;

import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.util.Date;

import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import java.awt.SystemColor;

import javax.swing.ImageIcon;
import javax.swing.border.TitledBorder;
import javax.swing.JButton;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.SwingConstants;
import javax.swing.UIManager;

public class Ventana_Menus extends JFrame {

	private JPanel contentPane;
	private final JMenuBar menuBar = new JMenuBar();
	private final JMenu mnIdioma = new JMenu("Idioma");
	private final JMenu mnAyuda = new JMenu("Ayuda");
	private final JMenu mnSalir = new JMenu("Salir");
	private final JRadioButtonMenuItem rdbtnmntmEspaol = new JRadioButtonMenuItem("Español");
	private final JRadioButtonMenuItem rdbtnmntmIngls = new JRadioButtonMenuItem("Ingles");
	private final ButtonGroup buttonGroup = new ButtonGroup();
	private final JMenuItem mntmAyuda = new JMenuItem("Ayuda");
	private final JMenuItem mntmAcercaDe = new JMenuItem("Acerca de...");
	private final JMenuItem mntmSalir = new JMenuItem("Salir");
	private final JLabel lblLogo = new JLabel("");
	private final JScrollPane scrollPane = new JScrollPane();
	private final JTextArea textArea = new JTextArea();
	private final JPanel panel_Pacientes = new JPanel();
	private final JButton btnComprobarStock = new JButton("Comprobar Stock");
	private static final String login="ipo1";
	private static final String nombre="Juan";
	private static final String apellidos="Garcia Perez";
	private static final String DNI="12345678-X";
	private static final String fecha_nacimiento="01/01/1969";
	private final JButton btnCerrarSesin = new JButton("Cerrar sesion");
	private final JButton btnPrepararPedido = new JButton("Preparar pedido");

	
	/**
	 * Create the frame.
	 */
	public Ventana_Menus(Empleado f) {
		setResizable(false);
		setTitle("Tienda de muebles VesperBeeper");
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent arg0) {
				JOptionPane.showMessageDialog(contentPane,"Gracias por utilizar nuestra aplicacion","Cerrar la aplicacion", JOptionPane.PLAIN_MESSAGE);
			}
		});
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 537, 468);
		java.util.Date fecha = new Date();
		String contenido = 
				" -- Usuario: "+ f.getUsuario()+
				"\n\n -- Nombre: "+ f.getNombre()+
				"\n\n -- Apellidos: "+ f.getApellidos()+
				"\n\n -- DNI: "+ f.getDNI()+
				"\n\n -- Fecha de nacimiento: "+ f.getfecha_nacimiento()+
				"\n\n -- Ultimo acceso: "+fecha.toString();
				textArea.setEditable(false);
				textArea.setBackground(SystemColor.menu);
				textArea.setText(contenido);
		{
			setJMenuBar(menuBar);
		}
		{
			menuBar.add(mnIdioma);
		}
		{
			buttonGroup.add(rdbtnmntmEspaol);
			rdbtnmntmEspaol.setSelected(true);
			mnIdioma.add(rdbtnmntmEspaol);
		}
		{
			buttonGroup.add(rdbtnmntmIngls);
			mnIdioma.add(rdbtnmntmIngls);
		}
		{
			menuBar.add(mnAyuda);
		}
		{
			mntmAyuda.addActionListener(new MntmAyudaActionListener());
			mnAyuda.add(mntmAyuda);
		}
		{
			mntmAcercaDe.addActionListener(new MntmAcercaDeActionListener());
			mnAyuda.add(mntmAcercaDe);
		}
		{
			menuBar.add(mnSalir);
		}
		{
			mntmSalir.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					JOptionPane.showMessageDialog(contentPane,"Gracias por utilizar nuestra aplicacion","Cerrar la aplicacion", JOptionPane.PLAIN_MESSAGE);
					System.exit(0);
				}
			});
			mnSalir.add(mntmSalir);
		}
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		GridBagLayout gbl_contentPane = new GridBagLayout();
		gbl_contentPane.columnWidths = new int[]{114, 77, 189, 140, 0};
		gbl_contentPane.rowHeights = new int[]{179, 0, 179, 0};
		gbl_contentPane.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
		contentPane.setLayout(gbl_contentPane);
		{
			GridBagConstraints gbc_lblLogo = new GridBagConstraints();
			gbc_lblLogo.gridwidth = 3;
			gbc_lblLogo.insets = new Insets(0, 0, 5, 5);
			gbc_lblLogo.gridx = 0;
			gbc_lblLogo.gridy = 0;
			lblLogo.setIcon(new ImageIcon(Ventana_Menus.class.getResource("/presentacion/logo.JPG")));
			//lblNewLabel.setIcon(new ImageIcon(Ventana_Menus.class.getResource("/presentacion/imagenes/logo_clinica.jpg")));
			contentPane.add(lblLogo, gbc_lblLogo);
		}
		{
			GridBagConstraints gbc_btnCerrarSesin = new GridBagConstraints();
			gbc_btnCerrarSesin.anchor = GridBagConstraints.NORTH;
			gbc_btnCerrarSesin.insets = new Insets(0, 0, 5, 0);
			gbc_btnCerrarSesin.gridx = 3;
			gbc_btnCerrarSesin.gridy = 0;
			btnCerrarSesin.setHorizontalAlignment(SwingConstants.LEFT);
			btnCerrarSesin.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					Ventana_Principal window =new Ventana_Principal();
					window.frmGestinDe.setVisible(true);
					hide();
				}
			});
			contentPane.add(btnCerrarSesin, gbc_btnCerrarSesin);
		}
		{
			GridBagConstraints gbc_panel_Pacientes = new GridBagConstraints();
			gbc_panel_Pacientes.gridheight = 2;
			gbc_panel_Pacientes.fill = GridBagConstraints.BOTH;
			gbc_panel_Pacientes.gridx = 3;
			gbc_panel_Pacientes.gridy = 1;
			panel_Pacientes.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Productos", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			contentPane.add(panel_Pacientes, gbc_panel_Pacientes);
		}
		{
			GridBagLayout gbl_panel_Pacientes = new GridBagLayout();
			gbl_panel_Pacientes.columnWidths = new int[]{115, 0};
			gbl_panel_Pacientes.rowHeights = new int[]{23, 23, 0, 0, 0, 0};
			gbl_panel_Pacientes.columnWeights = new double[]{0.0, Double.MIN_VALUE};
			gbl_panel_Pacientes.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
			panel_Pacientes.setLayout(gbl_panel_Pacientes);
		}
		btnComprobarStock.addActionListener(new BtnComprobarStockActionListener());
		GridBagConstraints gbc_btnComprobarStock = new GridBagConstraints();
		gbc_btnComprobarStock.anchor = GridBagConstraints.NORTHEAST;
		gbc_btnComprobarStock.insets = new Insets(0, 0, 5, 0);
		gbc_btnComprobarStock.gridx = 0;
		gbc_btnComprobarStock.gridy = 1;
		panel_Pacientes.add(btnComprobarStock, gbc_btnComprobarStock);
		{
			GridBagConstraints gbc_btnPrepararPedido = new GridBagConstraints();
			gbc_btnPrepararPedido.insets = new Insets(0, 0, 5, 0);
			gbc_btnPrepararPedido.anchor = GridBagConstraints.NORTH;
			gbc_btnPrepararPedido.gridx = 0;
			gbc_btnPrepararPedido.gridy = 3;
			btnPrepararPedido.addActionListener(new BtnPrepararPedidoActionListener());
			panel_Pacientes.add(btnPrepararPedido, gbc_btnPrepararPedido);
		}
		{
			GridBagConstraints gbc_scrollPane = new GridBagConstraints();
			gbc_scrollPane.gridheight = 2;
			gbc_scrollPane.gridwidth = 3;
			gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
			gbc_scrollPane.fill = GridBagConstraints.BOTH;
			gbc_scrollPane.gridx = 0;
			gbc_scrollPane.gridy = 1;
			contentPane.add(scrollPane, gbc_scrollPane);
		}
		{
			scrollPane.setViewportView(textArea);
		}
	}
	private class BtnComprobarStockActionListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			Datos_Productos ventana_tabla = new Datos_Productos();
			ventana_tabla.setVisible(true);
		}
	}
	private class MntmAyudaActionListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			JOptionPane.showMessageDialog(contentPane, "Documentacion almacenada en la pagina:\n https://code.google.com/p/vesperbeeper-2013-2014/", "Ayuda", JOptionPane.PLAIN_MESSAGE);
		}
	}
	private class MntmAcercaDeActionListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			JOptionPane.showMessageDialog(contentPane,"Version 1.0 \nAutores: Javier Chaves Romero, Angel Espinosa Aranda, Andres Felipe Alcalde Solarte y Francisco Crespo Ramos ",
					"Acerca de Gestion de Tienda de muebles", JOptionPane.PLAIN_MESSAGE);
		}
	}
	private class BtnPrepararPedidoActionListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			Pedido ventana_pedido = new Pedido();
			ventana_pedido.setVisible(true);
		}
	}
}
